import { Injectable } from '@nestjs/common';

@Injectable()
export class UploadService {
  create(file: Express.Multer.File) {
    if (!file) {
      return {
        code: 400,
        message: 'Only image files are allowed!',
      };
    }
    return {
      code: 200,
      data: {
        name: file.originalname,
        url: `http://localhost:1222/static/uploads/${file.filename}`,
        type: file.mimetype,
        size: file.size,
        ext: file.mimetype.split('/')[1],
      },
      message: 'success',
    };
  }
}
